<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Config;

use think\Db;
/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];
	
	/**
	 * 获取系统信息
	 *
	 */
	public function getsysteminfo()
	{
		$list = Db::name('admin')->where('id', 1)->find();
		$data['images'] = $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .$list['avatar'];
		
		$config = Db::name('config')->select();
		$data['name'] = $config[0]['value'];
		$data['beian'] = $config[1]['value'];
		$data['version'] = $config[3]['value'];
		$this->success('请求成功',$data);
	}
	
	/**
	 * 首页菜单
	 *
	 */
	public function getmenus()
	{
		
		$bannerlist = [
			[
				'image'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/banner1.jpg',
			],
			[
				'image'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/banner2.jpg',
			],
			[
				'image'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/banner1.jpg',
			]
		];
        $menus = [
			[
				'title'=>'商品管理',
				'info'=>[[
						'title'=> '商品分类',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m0.png',
						'url'=> '/pages/commodity/type',
					], [
						'title'=> '商品信息',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m1.png',
						'url'=> '/pages/commodity/commodityinfo',
					], [
						'title'=> '商品单位',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m2.png',
						'url'=> '/pages/commodity/unit',
					]
				],
			],[
				'title'=>'基础信息',
				'info'=>[[
						'title'=> '供应商管理',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m3.png',
						'url'=>'/pages/information/supplier/supplierlist'
					], [
						'title'=> '仓库分区',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m4.png',
						'url'=>'/pages/information/partition/index'
					], [
						'title'=> '仓库信息',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m5.png',
						'url'=>'/pages/information/warehouse/index'
					], [
						'iconname'=> 'bookmark-fill',
						'title'=> '客户信息',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m6.png',
						'url'=>'/pages/information/customerinfo/index'
					]
				],
			],[
				'title'=>'采购管理',
				'info'=>[[
						'title'=> '采购入库',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m7.png',
						'url'=>'/pages/purchase/addorder'
					],[
						'title'=> '采购订单',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m8.png',
						'url'=>'/pages/purchase/order'
					],[
						'title'=> '采购退单',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m9.png',
						'url'=>'/pages/purchase/addretire'
					],[
						'title'=> '退货单',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m10.png',
						'url'=>'/pages/purchase/retire'
					]
				],
			]
			,[
				'title'=>'销售管理',
				'info'=>[[
						'title'=> '销售出库',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m11.png',
						'url'=>'/pages/sell/addorder'
					],[
						'title'=> '销售订单',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m12.png',
						'url'=>'/pages/sell/order'
					]
				],
			]
		];
		$data['bannerlist'] = $bannerlist;
		$data['menus'] = $menus;
		$this->success('请求成功',$data);
	}
	
	
	/**
	 * 首页菜单
	 *
	 */
	public function getmenus2()
	{
		
	    $menus = [
			[
				'title'=>'快速采购',
				'info'=>[[
						'title'=> '采购入库',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m7.png',
						'url'=>'/pages/purchase/addorder'
					],[
						'title'=> '采购退单',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m9.png',
						'url'=>'/pages/purchase/addretire'
					]
				],
			]
			,[
				'title'=>'快速销售',
				'info'=>[[
						'title'=> '销售出库',
						'src'=> $this->request->scheme() . "://".$_SERVER["HTTP_HOST"] .'/assets/res/m11.png',
						'url'=>'/pages/sell/addorder'
					]
				],
			]
		];
		$data['menus'] = $menus;
		$this->success('请求成功',$data);
	}
}
